<template>
	<view class="indent">
		<!-- <view class="scroll-h">
			<view v-for="(res,i) in ptabBars" :key="res.id" class="uni-tab-item" :id="res.id" :data-current="i"
				@click="pontabtap">
				<text class="uni-tab-item-title"
					:class="ptabIndex == i ? 'uni-tab-item-title-active' : ''">{{res.name || ''}}</text>
				<text v-show="ptabIndex == i" class="uni-tab-item-text"></text>
			</view>
		</view> -->
		<view class="dqgDom" v-show="ptabIndex === 0">
			<dqg ref="dqgDom" :page="page"/>
		</view>

		<!-- <view class="" v-show="ptabIndex === 1">
			<cqg ref="cqgDom" />
		</view> -->

	</view>

</template>
<script>
	// import dqg from "./dqg.vue"
	// import cqg from "./cqg.vue"

	function getDate(type, index = 0, state = 0) {
		const dates = new Date();
		const date = new Date(dates)
		date.setDate(date.getDate() + index) // 获取index天后的日期
		let year = date.getFullYear();
		let month = date.getMonth() + 1;
		let day = date.getDate();

		if (type === 'start') {
			year = year - 10;
		} else if (type === 'end') {
			year = year + 10;
		}
		month = month > 9 ? month : '0' + month;;
		day = day > 9 ? day : '0' + day;
		if (state == 0) return `${year}-${month}-${day}`;
		else return `${year}-${month}`;
	}
	export default {
		components: {
			// dqg,
			// cqg
		},
		data() {
			return {
				ptabIndex: 0, // 0短期工 1长期工
				page: 1,
				ptabBars: [{
					name: '短期工',
					id: 'dqg'
				}, {
					name: '长期工',
					id: 'cqg7'
				}],
			}
		},
		onShow() {
			this.$refs.dqgDom.clearSubscribeList()
			this.$refs.dqgDom.getOrderList()
			this.$refs.cqgDom.getOrderList()
			
		},
		async onLoad() {
			let location = await uni.getLocation()
			uni.setStorageSync('latitude', location[1].latitude);
			uni.setStorageSync('longitude', location[1].longitude);
		},
		onReachBottom() {
			this.$refs.dqgDom.setReachBottom()
			this.$refs.cqgDom.setReachBottom()

		},
		onPullDownRefresh() {
			let _this = this
			if (_this.ptabIndex === 0) {
				setTimeout(function() {
					setTimeout(() => {
						uni.showToast({
							title: "刷新成功",
							icon: "none",
						})
					}, 300);
					_this.$refs.dqgDom.clearSubscribeList()
					_this.$refs.dqgDom.getOrderList()
					uni.stopPullDownRefresh();
				}, 1000);
			} else if (_this.ptabIndex === 1) {
				setTimeout(function() {
					setTimeout(() => {
						uni.showToast({
							title: "刷新成功",
							icon: "none",
						})
					}, 300);
					_this.$refs.cqgDom.clearSubscribeList()
					_this.$refs.cqgDom.getOrderList()
					uni.stopPullDownRefresh();
				}, 1000);
			}
		},
		methods: {
			// 长期工 短期工切换
			pontabtap(e) {
				let index = e.target.dataset.current || e.currentTarget.dataset.current
				this.ptabIndex = index
				if (this.ptabIndex === 0) this.$refs.dqgDom.getOrderList()
				if (this.ptabIndex === 1) this.$refs.cqgDom.getOrderList()
			},

		}
	}
</script>

<style lang="scss">
	.uni-card__header-content{
		justify-content: flex-start!important;
	}
	.indent {
		position: relative;

		height: 100vh;

		.dqgDom {
			padding-bottom: 110rpx;
		}

		.scroll-h {
			display: flex;
			align-items: center;
			width: 100%;
			height: 100rpx;
			background-color: #ffffff;

			.uni-tab-item {
				position: relative;
				flex: 1;
				display: inline-block;
				text-align: center;

				.uni-tab-item-title {
					color: rgba($color: #000000, $alpha: 0.7);
					font-size: 28rpx;
					height: 80rpx;
					line-height: 80rpx;
					opacity: 0.7;
				}

				.uni-tab-item-text {
					position: absolute;
					bottom: 8rpx;
					left: 50%;
					transform: translateX(-50%);
					height: 4rpx;
					width: 36rpx;
					background: linear-gradient(255deg, #8dc9f1, #d8eefc);
					border-radius: 2rpx;
				}

				.uni-tab-item-title-active {
					color: #000000;
					font-size: 34rpx;
					font-weight: 600;
				}
			}
		}
	}


	.finishPopup-box {

		.finishPopup-add {
			display: flex;
			height: 70rpx;
			// flex-direction:column
		}

		width: 450rpx;
		min-height: 200rpx;

		.finishPopup-fangxing {
			margin: 0rpx 20rpx 0 13rpx;
			width: 130rpx;
			height: 35rpx;

			.uni-select {
				padding-left: 10rpx;
				padding-bottom: 5rpx;
			}

			.uni-select__input-box {
				min-height: 35rpx;
			}

			.uni-select__input-text {
				width: 130rpx;
				// height: 40rpx;
				font-size: 24rpx;
				outline: medium none;
			}

			.uni-stat__select {
				padding: 0;

				.uni-select__selector-item {
					font-size: 24rpx;
				}
			}
		}

		.finishPopup-numner {
			width: 140rpx;
			height: 35rpx;
			margin: 5rpx 8rpx 0 50rpx;

			.uni-numbox__minus,
			.uni-numbox__plus {
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				background-color: #fff !important;
				border: 2rpx solid #50E28C;
				box-sizing: border-box;
			}

			.uni-numbox__minus {
				height: 48rpx;
			}

			.uni-numbox__minus text {
				margin-bottom: 6rpx;
			}

			.uni-numbox__plus text {
				margin-bottom: 6rpx;
			}

			.uni-numbox--text {
				color: #50E28C !important;
			}

			.uni-numbox__value {
				background-color: #fff !important;
			}
		}

		.addfangxing {
			width: 335rpx;
			height: 35rpx;
			font-size: 24rpx;
			margin-left: 13rpx;
			line-height: 35rpx;
			text-align: center;
			border: 1rpx dashed #50E28C;
			color: #50E28C;
		}

	}
</style>
